package com.qi.qipay.commons.utils;

import java.util.Random;
import java.util.UUID;

public class StringUtil {

    public static String randomString(int length) {
        String englishUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String englishLower = englishUpper.toLowerCase();
        String numberStr = "0123456789";
        String signStr = "`~!@#$%^&*()_+-=[]{}|;':,./<>?";
        StringBuilder resultStr = new StringBuilder();
        resultStr.append(englishUpper);
        resultStr.append(englishLower);
        resultStr.append(numberStr);
        resultStr.append(signStr);
        Random random = new Random();
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(resultStr.length());
            result.append(resultStr.charAt(index));
        }
        return result.toString();
    }

    public static String randomUUID() {
        return UUID.randomUUID().toString().replace("-","");
    }
}
